 <?php
		session_start(); 
		include "function/libfunc.php";
 			if (!empty($_SESSION['username']) && !empty($_SESSION['password'])) { 

                              		$link = koneksi_db();
                                        $id=$_GET['idproduk'];
                                        $sql = "select * from produk WHERE idproduk='$id' ";
                                        $hasil = mysql_query($sql,$link) or exit("Error query: <b>".$sql."</b>.");
										$data = mysql_fetch_assoc($hasil);
?>

                    <div class="row-fluid">

                        <div class="span12">

                            <div class="box">

                                <div class="title">

                                    <h4>
                                        <span class="icon16 icomoon-icon-equalizer-2"></span>
                                        <span>Edit Data Produk | <a href="produk.php">Lihat produk</a></span>
                                    </h4>
                                    
                                </div>
                                
                                <div class="content">
                                    <form name="tambahproduk" id="tambahproduk" class="form-horizontal" action="proseseditproduk.php" method="post" enctype="multipart/form-data">
                                    
										 
										<div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="focusedInput">ID Produk</label>
                                                    <input type="hidden" name="idmedia" value="<?php echo $data['idmedia']; ?>" />
                                                    <input name="idproduk" readonly class="span7 focused" id="namaproduk" type="text" value="<?php echo $data['idproduk']; ?>" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="focusedInput">Nama Produk</label>
                                                    <input name="namaproduk" class="span7 focused" id="namaproduk" type="text" value="<?php echo $data['nama']; ?>" />
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="checkboxes">Nama Kategori</label>
                                                    <div class="span7 controls">   
                                                        <select name="idkategori" id="idkategori">
                                        <?php
                                        $link = koneksi_db();
                                        $sql = "select * from kategori ORDER BY namakategori ASC";
                                        $hasil = mysql_query($sql,$link) or exit("Error query: <b>".$sql."</b>.");
										while($data1= mysql_fetch_assoc($hasil)){
										?>
                                                            <option value="<?php echo $data1['idkategori']; ?>"><?php echo $data1['namakategori']; ?></option>
                                                            <?php
															}
															?>
                                                        </select>
                                                    </div> 
                                                </div>
                                            </div> 
                                        </div>
   

                                        <div class="form-row row-fluid">
                                            <div class="span12">
                                                <div class="row-fluid">   
                                                   
                                 <textarea class="tinymce span4" id="deskripsiproduk" name="deskripsi" style="width:100%"><?php echo $data['deskripsi']; ?></textarea>
                                                </div>
                                            </div>  
                                        </div>
                                        
                                        
                                     <div class="row-fluid">

                        <div class="span6">

                            <div class="box">
                                <div class="content">
                                   
                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span2" for="textarea">Gambar</label>
                                                    <input type="file" name="gambar" id="gambar" />
                                                </div>
                                            </div>  
                                        </div>

                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span2" for="prependedInput">Harga</label>
                                                    <div class="input-prepend">
                                                        <span class="add-on">Rp.</span><input value="<?php echo $data['harga']; ?>" class="span6" id="harga" size="16" type="text" name="harga" />
                                                    </div>
                                   					<span class="help-block blue span6">Isi dengan angka!</span>
                                                </div>
                                            </div>
                                        </div>
                                        
                                    	<div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span2" for="appendedInput">Stok</label>
                                                    <div class="input-append">
                                                        <input class="span6" id="stok" value="<?php echo $data['stok']; ?>" name="stok" size="16" type="text" /><span class="add-on">Produk</span>
                                                    </div>
              										<span class="help-block blue span6">Isi dengan angka!</span>
                                                </div>
                                            </div>
                                        </div>
                                </div>

                            </div><!-- End .box -->

                        </div><!-- End .span6 -->
                        

                        <div class="span6">

                            <div class="box">
                                <div class="content">
                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="appendedInput">Diskon</label>
                                                    <div class="input-append">
                                                        <input class="span8" id="diskon" value="<?php echo $data['diskon']; ?>" name="diskon" size="16" type="text" /><span class="add-on">%</span>
                                                    </div>
                                                    <span class="help-block blue span6">Isi dengan angka!</span>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="checkboxes">Status</label>
                                                    <div class="span8 controls">   
                                                        <select name="status" id="status">
           														<option value="Jual">Jual</option>
                                                                <option value="Baru">Baru</option>
                                                                <option value="Promo">Promo</option>
                                                                <option value="Limit">Limit</option>
                                                          
                                                        </select>
                                                    </div> 
                                                </div>
                                            </div> 
                                        </div>
   

                                        <div class="form-row row-fluid">
                                            <div class="span11">
                                                <div class="row-fluid">
                                                    <label class="form-label span4" for="appendedInput">Kode</label>
                                                    <div class="input-append">
                                                        <input class="span8" id="kode" value="<?php echo $data['kode']; ?>"  name="kode" size="16" type="text" required />
                                                    </div>
                                                    <span class="help-block blue span6">Isi dengan angka!</span>
                                                    <span class="help-block blue span6"></span>
                                                    <span class="help-block blue span6"></span>
                                                    <span class="help-block blue span6"></span>
                                                </div>
                                            </div>
                                        </div>
                                </div>

                            </div><!-- End .box -->

                        </div><!-- End .span6 -->  
                    
                                    </div>
                               <div class="form-actions">
                                           <button type="submit" class="btn btn-info">Simpan</button>
                                           
                                           <button type="button" class="btn" onclick="window.history.back()">Cancel</button>
                                        </div> 
                                    </form>
                                 
                                </div>

                            </div><!-- End .box -->

                        </div><!-- End .span6 -->
                        
 <?php   
    }else {
echo "<script language='javascript'>window.location = '../admin/'</script>";
}
?>
